import request from "@/utils/request";

// 商品列表
export function listGoodsInfo(query) {
  return request({
    url: "/admin/goodsInfoController/list",
    method: "get",
    params: query
  });
}

//新增/修改商品
export function saveOrUpdate(data) {
  return request({
    url: '/admin/goodsInfoController/saveOrUpdate',
    method: 'post',
    data: data
  })
}

//审核商品
export function audit(data) {
  return request({
    url: "/admin/goodsInfoController/audit",
    method: "put",
    data: data,
  });
}

//上下架商品
export function putOnOrDown(data) {
  return request({
    url: "/admin/goodsInfoController/putOnOrDown",
    method: "put",
    data: data,
  });
}

//删除商品
export function removeGoodsInfo(goodsId) {
  return request({
    url: "/admin/goodsInfoController/" + goodsId,
    method: "delete",
  });
}


//图片上传
export function uploadImg(data) {
  return request({
    url: '/admin/upload/uploadImg/2',
    method: 'post',
    data: data
  })
}

// 查询商品分类列表
export function getGoodsCategoryInfoList() {
  return request({
    url: "/admin/goodsCategoryController/list",
    method: "get",
  });
}

//新增商品分类
export function addGoodsCategoryInfo(data) {
  return request({
    url: "/admin/goodsCategoryController/add",
    method: "post",
    data: data,
  });
}

//删除商品分类
export function removeGoodsCategoryInfo(categoryId) {
  return request({
    url: "/admin/goodsCategoryController/remove?categoryId=" + categoryId,
    method: "delete",
  });
}

// 修改商品分类
export function updateGoodsCategoryInfo(data) {
  return request({
    url: "/admin/goodsCategoryController/update",
    method: "post",
    data: data,
  });
}

// 查询商品分类列表
export function listGoodsCategory() {
  return request({
    url: "/admin/goodsCategoryController/listGoodsCategory",
    method: "get",
  });
}

//商品排序/admin/goodsInfoController/sort
export function goodsInfoControllersort(data) {
  return request({
    url: "/admin/goodsInfoController/sort",
    method: "put",
    data: data,
  });
}
